
import { _decorator, Node, MeshRenderer, Material, Color, Mesh, TERRAIN_HEIGHT_BASE, utils, pipeline, Vec4, Vec3 } from 'cc';
import yyComponent from '../../Script/Common/yyComponent';
import GameConfig from '../../Script/GameSpecial/GameConfig';
const { ccclass, property } = _decorator;

@ccclass('AtkScopeTrapper')
export class AtkScopeTrapper extends yyComponent {

    public setAtkPos(posArr: Vec3[]) {
        let nodes = this.node.children;
        let c = nodes.length;
        for (let i = 0; i < c; ++i) {
            nodes[i].setPosition(posArr[i]);
        }
    }

    public setColor(color) {
        let nodes = this.node.children;
        let c = nodes.length;
        for (let i = 0; i < c; ++i) {
            nodes[i].getComponent(MeshRenderer).getMaterialInstance(0).setProperty("mainColor", color);
        }
    }

    public setAtkScale(roleScale: number) {
        let s = 1 / roleScale;
        this.node.setScale(s, s, s);
        let nodes = this.node.children;
        let c = nodes.length;
        s = roleScale * 0.8;
        for (let i = 0; i < c; ++i) {
            nodes[i].setScale(s, s, s);
        }
    }
}
